package net.sina.realtime.traffic.function;

import net.sina.realtime.traffic.bean.TrafficFlowType;
import org.apache.flink.api.common.functions.ReduceFunction;

public class FlowReportReduceFunction implements ReduceFunction<TrafficFlowType> {

    @Override
    public TrafficFlowType reduce(TrafficFlowType TrafficFlowType, TrafficFlowType bean) throws Exception {
        // todo TrafficFlowType：表示增加计算中间结果；bean：表示窗口中每条数据
        // 增量计算
        TrafficFlowType.setVehicleTypeCount(TrafficFlowType.getVehicleTypeCount() + bean.getVehicleTypeCount());
        // 返回结果
        return TrafficFlowType;
    }
}
